package com.atguigu.cos.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author shkstart
 * @create 2022-09-17 20:22
 */
//当项目已启动，spring接口，spring加载之后，执行接口一个方法
@Component
//@ConfigurationProperties(prefix = "qcloud.cos.file")
public class ConstantPropertiesUtils implements InitializingBean {

    //读取配置文件内容
    @Value("${qcloud.cos.file.regionId}")
    private String regionId;

    @Value("${qcloud.cos.file.secretId}")
    private String secretId;

    @Value("${qcloud.cos.file.secretKey}")
    private String secretKey;

    @Value("${qcloud.cos.file.bucketName}")
    private String bucketName;

    //定义公开静态变量
    public static String REGION_ID;

    public static String SECRET_ID;

    public static String SECRET_KEY;

    public static String BUCKET_NAME;



    @Override
    public void afterPropertiesSet() throws Exception {
        REGION_ID = regionId;
        SECRET_ID = secretId;
        SECRET_KEY = secretKey;
        BUCKET_NAME = bucketName;
    }
}
